<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link type="text/css" rel="stylesheet" href="../../resource/css/reset.css"/>
        <link type="text/css" rel="stylesheet" href="../../resource/css/api_index.css"/>
        <script type="text/javascript" src="../../resource/js/fw/jquery-1.8.3.min.js"></script>
    </head>
    <body>
        <div class="pk-wrap">

            <div class="pk-unit-wrap">
                <div class="pk-unit">
                    <h1 class="clearfix">
                        <span class="pk-color-title">Array.slice()</span>
                        <span class="pk-float-right pk-tip">Core > Object > Array > slice</span>
                    </h1>
                </div>
                <div class="pk-unit">
                    <div class="pk-unit-with-style">
                        <div class="pk-unit-tag">Description</div>
                        <pre>    slice()返回array的片段，或称为子数组。返回的数组包含从start一直到end之间的所有元素（包含start指定的元素，但不包含end指定的元素）。如果没有指定end，返回的数组包含从start到array尾部的所有元素。
    注意slice()没有修改数组。如果想要移除数组的一部分，请使用Array．splice()。</pre>
                    </div>
                </div>
            </div>

                        <div class="pk-unit-wrap">
                <div class="pk-unit">
                    <h1 class="clearfix">
                        <span class="pk-color-title pk-italic">参数 array.slice(start[,end])</span>
                    </h1>
                </div>
                <div class="pk-unit">
                    <table>
                        <thead>
                            <tr>
                                <th class="pk-w120">参数名</th>
                                <th>描述</th>
                            </tr>
                        </thead>
                        <tbody>
                                                        <tr>
                                <td>start</td>
                                <td>数组片段开始处的数组序号。如果为负数，则表示从数组的尾部开始计算。也就是说，-1代表最后一个元素，-2代表倒数第二个元素，以此类推。</td>
                            </tr>
                                                        <tr>
                                <td>end</td>
                                <td>数组片段结束处的后一个元素的数组序号。如果没有指定，该片段会包含从start开始到数组尾部的所有数组元素。如果为负数，则表示从数组的尾部开始计算。</td>
                            </tr>
                                                    </tbody>
                    </table>
                </div>
            </div>
            
                        <div class="pk-unit-wrap">
                <div class="pk-unit">
                    <h1 class="clearfix">
                        <span class="pk-color-title pk-italic">返回值</span>
                    </h1>
                </div>
                <div class="pk-unit">
                    <div class="pk-unit-with-style">
                        <div class="pk-unit-tag">Description</div>
                        <pre>一个新数组，包含array中从start一直到end之间的所有元素（包含start指定的元素，但不包含end指定的元素）。</pre>
                    </div>
                </div>
            </div>
            
            
            
                        <div class="pk-unit-wrap">
                <div class="pk-unit">
                    <h1 class="clearfix">
                        <span class="pk-color-title pk-italic">代码示例</span>
                    </h1>
                </div>
                <div class="pk-unit">
                    <div class="pk-unit-with-style pk-code">
                        <div class="pk-unit-tag">
                            <span>Code</span>
                        </div>
                        <div class="pk-unit-fns">
                            <a href="javascript:" title="Fold or unfold the code" data-rel="fold-btn">-Fold</a>
                            <a href="javascript:" data-rel="copy-code">Copy</a>
                        </div>
                        <pre><span class="pk-code-key">var</span> a = [1,2,3,4,5];
a.slice(0,3);   // Returns [1,2,3]
a.slice(3);      // Returns [4,5]
a.slice(1,-1);  // Returns [2,3,4]
a.slice(-3,-2); // Returns [3]; buggy <span class="pk-code-key">in </span>IE 4: returns [1,2,3]</pre>
                    </div>
                </div>
            </div>

            <script type="text/javascript" src="../../resource/js/fw/clipboard/ZeroClipboard.min.js"></script>
            <script type="text/javascript" src="../../resource/js/api_index.js"></script>
            <script type="text/javascript">
                if(window.clipboardData){
                    $('a[data-rel="copy-code"]').click(function(){
                        window.clipboardData.setData('text',$(this).parent().next().text());
                        alert("Copy successfully!");
                    });
                }else{
                    clipboard($('a[data-rel="copy-code"]'),"../../resource/js/fw/clipboard/ZeroClipboard.swf");
                }
            </script>
                    </div>
    </body>
</html>
